package algo.search;

public class TwoDivideSearch {
	public static void main(String args[]) {
		int k[] = new int[]{1,3,6,7,11,16,19,22,33,44,76,101,102,205,305};
		int startPoint = -1;
		int endPoint = k.length;
		
		int findKey = 33;
		int count = 1;
		
		System.out.println(endPoint);
		
		for(int i=k.length/2;(endPoint-startPoint)>1;i=(endPoint-startPoint)/2) {
			int pos = startPoint+i;
			int currVal = k[pos];
			if(currVal == findKey) {
				System.out.println(count+" Find "+(startPoint+i));
				break;
			} else if(currVal > findKey) {
				endPoint = pos;
			} else if(currVal < findKey) {
				startPoint = pos;
			}
			System.out.println(count+" Iter "+i+" : "+currVal+" : "+startPoint+" , "+endPoint);
			count++;
			try {
				Thread.sleep(1000);
			} catch (Exception e) {
				// TODO: handle exception
			}
		}
	}
}
